package vcp.client.GUI.mvc.controller;

import vcp.client.GUI.mvc.model.UIAbstractModel;
import vcp.client.GUI.mvc.view.UIAbstractView;
import vcp.client.GUI.mvc.view.UIOnSiteView;
import vcp.enums.Screen;
import vcp.enums.SiteEnum;

/**
 * 
 * @author VCP team
 * 
 *         <p>
 *         OnSite controller, manages customers check-in/check-out in/from VCP
 *         system
 *         </p>
 *         responsible <b> <u>only</u> </b> for the OnSite screen management
 * 
 * @see SiteEnum
 */
public class UIOnSiteController extends UIAbstractController
{
	/**
	 * Application onSite panel
	 */
	private final UIOnSiteView view;

	private SiteEnum selectedSite;

	/**
	 * 
	 * @param view
	 *            : OnSite GUI panel
	 */
	public UIOnSiteController ( UIOnSiteView view )
	{
		super(Screen.ONSITE);
		this.view = view;
		this.selectedSite = SiteEnum.SITE_1;

		this.setupListeners();
	}

	// ****************************************************************************************************************************
	// UIAbstractController methods ***
	// ****************************************************************************************************************************
	@Override
	public UIAbstractView getView ()
	{
		return this.view;
	}

	@Override
	public UIAbstractModel getModel ()
	{
		return null;
	}

	@Override
	public void clearMVC ()
	{
	}

	@Override
	protected void setupListeners ()
	{
		this.view.setControllerDelegate(this);
	}

	// ****************************************************************************************************************************
	// IControllerViewDelegate methods ***
	// ****************************************************************************************************************************

	@Override
	public void onButtonPress ( Object object )
	{
		if ( object instanceof Screen )
		{
			Screen newScreen = (Screen) object;
			this.parentDelegate.loadMVCWithData(newScreen, this.selectedSite);
		}
		else
		{
			SiteEnum newSite = (SiteEnum) object;
			this.selectedSite = newSite;
		}
	}
}
